package com.example.springbootstudy.service.Impt;

import com.example.springbootstudy.Mapper.DeptMapper;
import com.example.springbootstudy.dao.DeptDao;
import com.example.springbootstudy.pojo.Dept;
import com.example.springbootstudy.pojo.Result;
import com.example.springbootstudy.service.DeptService;
import lombok.experimental.PackagePrivate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class AddDeptServiceImpl implements DeptService {
    @Autowired
    DeptDao deptDao;
    @Autowired
    DeptMapper deptMapper;
    @Override
    public String addDeptService(String ask) {
        if (ask.equals("用户来请求啦")){
            //访问数据访问层
            String s = deptDao.addDeptDao("请添加数据");
            return s;
        }
        return "业务添加失败";
    }
    public List<Dept> selectAllService(){

        return deptMapper.selectAllDao();
    }
    public Result deleteAllService(Integer id){
        deptMapper.deleteAllDao(id);
        return Result.success();
    }
    public Result insertAllSarvice(Dept dept){
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insertAllDao(dept);
        return Result.success();
    }
}
